<template>
  <div class="index_wrap">
    <el-form status-icon ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="账号" prop="account">
        <el-input v-model="account" autocomplete="off"></el-input>
      </el-form-item>            
      <el-form-item label="密码" prop="pass">
        <el-input type="password" v-model="password" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="doLogin">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import { defineComponent, getCurrentInstance, onMounted, onUpdated, reactive, ref, toRefs, watchEffect } from 'vue'
import Cookies from 'js-cookie'
import { useStore } from '../store';
import { ElMessage } from 'element-plus'
export default defineComponent({
  setup(){
    const store = useStore();
    const {ctx}:any = getCurrentInstance();
    const ruleForm = reactive({
      account:"admin",
      password:'123456' 
    })
    const doLogin = () =>{
      if(ruleForm.account=="admin"&&ruleForm.password=="123456"){
        ElMessage.success("登录成功!");
        Cookies.set('token',"123456");
        ctx.$router.push('/list');
      }else{
        ElMessage.error("登录失败！");
      }
    }
    return{
      doLogin,
      ...toRefs(ruleForm)
    }
  }
});
</script>

<style lang="stylus">
.index_wrap
    background-color:#FFF
    height 100vh
    width:100%
</style>